package com.atguigu.mytest;

import com.atguigu.mytest.common.utils.R;
import jdk.nashorn.internal.ir.CallNode;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<>();
        persons.add(new Person("张三", 20));
        persons.add(new Person("张三", 26));
        persons.add(new Person("李四", 30));
        persons.add(new Person("王五", 40));
        Map<String, Integer> collect = persons.stream().collect(Collectors.toMap(Person::getName, Person::getAge, (k, v) -> v));
        System.out.println(collect);
    }
}


class Person {
    private String name;
    private int age;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}